package com.itboye.textileexpes.repository;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.reflect.TypeToken;
import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.interfaces.IUserRepository;
import com.itboye.textileexpes.beans.AppUpdateBean;
import com.itboye.textileexpes.beans.Category_TypeTwo;
import com.itboye.textileexpes.beans.ForresterBeans;
import com.itboye.textileexpes.beans.NewMeesgeBeans;
import com.itboye.textileexpes.beans.NewsMessgeBeans;
import com.itboye.textileexpes.beans.PersonDataBean;
import com.itboye.textileexpes.beans.RootBean;
import com.itboye.textileexpes.interfaces.IAppUpdate;
import com.itboye.textileexpes.interfaces.ICategory;
import com.itboye.textileexpes.interfaces.IMainCategory;
import com.itboye.textileexpes.interfaces.IMainCategoryTypeTwo;
import com.itboye.textileexpes.json.ByJsonRequest.Builder;
import com.itboye.textileexpres.base.BaseErrorListener;
import com.itboye.textileexpres.base.BaseNetRepository;
import com.itboye.textileexpres.base.BaseSuccessReqListener;

public class MainCategoryRepositoryTypeTwo extends BaseNetRepository implements
		IMainCategoryTypeTwo<Category_TypeTwo> {
	/***
	 * 查询类目
	 */
	public static final String Category = "By_Category_queryMainCategory";
	// 收藏类目
	public static final String Collection = "By_Favorites_cate";
	public static final String Category_son = "By_Category_querySubCategory";
	public static String NewMeesge = "By_Message_query";// 消息

	public MainCategoryRepositoryTypeTwo(ICompleteListener listener) {
		// TODO Auto-generated constructor stub
		super(listener);
	}

	@Override
	public void queryCate(int id) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<List<Category_TypeTwo>>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("cate_id", id);

		// START
		(new Builder<List<Category_TypeTwo>>())
				.setTypeVerParamsAndReturnClass(Category_son, apiVer, params,
						type)
				.requestListener(
						new BaseSuccessReqListener<List<Category_TypeTwo>>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
	}

	@Override
	public void add(Category_TypeTwo model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(Category_TypeTwo model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(Category_TypeTwo model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(Category_TypeTwo model) {
		// TODO Auto-generated method stub

	}

	@Override
	public List<Category_TypeTwo> query(Category_TypeTwo model) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void onMesssge(String uid, String msg_type, String page_index,
			String page_size) {
		// TODO Auto-generated method stub
		Type type = new TypeToken<List<NewMeesgeBeans>>() {
		}.getType();
		String apiVer = "100";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("uid", uid);
		params.put("msg_type", msg_type);
		params.put("page_index", page_index);
		params.put("page_size", page_size);

		// START
		(new Builder<List<NewMeesgeBeans>>())
				.setTypeVerParamsAndReturnClass(NewMeesge, apiVer, params,
						type)
				.requestListener(
						new BaseSuccessReqListener<List<NewMeesgeBeans>>(
								getListener()))
				.errorListener(new BaseErrorListener(getListener()))
				.desEncodeThenBuildAndSend();
		
	}

}
